home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / cardpkg_1.3.lha / CardPkg / CardVBigImages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-20  |  4.6 KB  |  153 lines

  1. /*** CardVBigImages.c ***/
  2.  
  3. /************************************************************
  4.  
  5.     TML's C Language Card Image Package  v1.1
  6.     January, 1993
  7.     Todd M. Lewis             (919) 776-7386
  8.     2601 Piedmont Drive
  9.     Sanford, NC  27330-9437
  10.     USA
  11. ************************************************************/
  12.  
  13. #include <exec/types.h>
  14. #include <intuition/intuition.h>
  15. #include <graphics/gfxbase.h>
  16. #include <graphics/gfxmacros.h>
  17. #include "CardVBigImages.h"
  18. #include "Cards.h"
  19.  
  20. #ifdef AZTEC_C
  21.   #include <functions.h>
  22. #endif
  23. #ifdef __SASC
  24.   #include <clib/graphics_protos.h>
  25. #endif
  26.  
  27. /**********************************************************************
  28. CardVBigBrush.c contains an array of UWORDs which holds the bitmap
  29. data for a deck of playing cards layed out in eight columns.  In
  30. all, 56 cards are defined in the following order:
  31.  
  32.   Spades Hearts  Clubs  Diamonds  Spades Hearts  Clubs  Diamonds
  33.     A       A       A       A       2       2       2       2
  34.     3       3       3       3       4       4       4       4
  35.     5       5       5       5       6       6       6       6
  36.     7       7       7       7       8       8       8       8
  37.     9       9       9       9      10      10      10      10
  38.     J       J       J       J       Q       Q       Q       Q
  39.     K       K       K       K     JOKER   BLANK   BACK    BLACK
  40.  
  41. Each card is 48 bits wide and 64 bits high, the edges of the cards
  42. do not overlap, so the total bitmap is 384(h)x512(v)x2 planes deep. In
  43. addition, another bitplane is defined which has the same shape as the 2
  44. mentioned above, but with all the pixels within the cards turned on. This
  45. bitplane is used as a mask with BltMaskBitMapRastPort() to round off the
  46. corners of the cards.
  47.  
  48. MAKE SURE THE CardVBigBrush DATA GET LOADED INTO CHIP RAM!  You may
  49. have to edit CardVBigBrush.c to add the "__chip" keyword, or you
  50. may have to use a link option, or run the ATOM facility on the
  51. final executable to make it load into chip ram.
  52.  
  53. The cards were designed with the following pen colors:
  54.  
  55.   pen | red  green blue
  56.   ----+----------------
  57.     0 |   0     4    12   (Blue)
  58.     1 |   0     0     0   (Black)
  59.     2 |  14    12    10   (Creamy White)
  60.     3 |  15     8     0   (Rusty Red)
  61.  
  62. **********************************************************************/
  63.  
  64. #include "CardVBigBrush.c"
  65.  
  66. struct  Image CardVBigBrushimage =
  67.  {
  68.    0,0,
  69.    512 , 384 , 3 ,
  70.    &CardVBigBrush[0],
  71.    0x1f,0x00,
  72.    NULL,
  73.  };
  74.  
  75. extern struct GfxBase *GfxBase;
  76.  
  77. BOOL ShowVBigCard( struct RastPort *rp, CardID_t Card, WORD dx, WORD dy )
  78.   {
  79.  
  80.     static struct BitMap bm;
  81.     static BOOL   bmInit = FALSE;
  82.     static UWORD *mask;
  83.     WORD          SourceX, SourceY;
  84.     WORD          suit, rank,x,y;
  85.  
  86.     if (!bmInit)
  87.       {
  88.         PLANEPTR tmp;
  89.         InitBitMap( &bm, 2L, 512L, 384L);
  90.         bm.Planes[0] = (PLANEPTR)&CardVBigBrush [ 0 ];
  91.         bm.Planes[1] = (PLANEPTR)&CardVBigBrush1[ 0 ];
  92.         mask         =           &CardVBigBrush2[ 0 ];
  93.  
  94.         /** Black and White are reversed prior to v35, so swap planes. **/
  95.         if ( CardColorSwapping && GfxBase->LibNode.lib_Version < 35 )
  96.           {
  97.             tmp = bm.Planes[0];
  98.                   bm.Planes[0] = bm.Planes[1];
  99.                                  bm.Planes[1] = tmp;
  100.           }
  101.         bmInit = 1;
  102.       }
  103.  
  104.     if ( Card == CARD_NONE ) /* Erase the card */
  105.       {
  106.         BYTE FgPen, DrawMode;
  107.         UBYTE Mask;
  108.         FgPen    = rp->FgPen;
  109.         DrawMode = rp->DrawMode;
  110.         Mask     = rp->Mask;
  111.         SetAPen( rp, 0 );
  112.         SetDrMd( rp, JAM1 );
  113.         SetWrMsk(rp, 0xff );
  114.         RectFill(rp, dx, dy, dx+CARD_VBIG_WIDTH-1, dy+CARD_VBIG_HEIGHT-1 );
  115.         SetWrMsk(rp, Mask );
  116.         SetDrMd( rp, DrawMode );
  117.         SetAPen( rp, FgPen );
  118.         return TRUE;
  119.       }
  120.  
  121.     if ( !(rank = CardRank( Card )) || !(suit = CardSuit( Card )) )
  122.       return FALSE;
  123.  
  124.     if ( suit == SUIT_SPECIAL )
  125.         {
  126.           y = 6;
  127.           x = 3 + rank;
  128.         }
  129.       else
  130.         {
  131.           x = (suit - 1) + (rank&1? 0 : 4 );
  132.           y = (rank - 1) / 2;
  133.         }
  134.  
  135.     SourceX = x * CARD_VBIG_WIDTH;
  136.     SourceY = y * CARD_VBIG_HEIGHT;
  137.  
  138.     BltMaskBitMapRastPort(
  139.        &bm,                                     /* Source BitMap */
  140.        SourceX,                                 /* Source X      */
  141.        SourceY,                                 /* Source Y      */
  142.        rp,                                      /* destRastPort  */
  143.        dx, dy,                                  /* destX, destY  */
  144.        CARD_VBIG_WIDTH, CARD_VBIG_HEIGHT,       /* sizeX, sizeY  */
  145.        0x00E0,                                  /* minterm       */
  146.        (APTR)mask                               /* bltMask       */
  147.        );
  148.  
  149.     return TRUE;
  150.   }
  151.  
  152.  
  153.